# -*- coding: utf-8 -*- 
# @Time : 2021/4/3 17:42 
# @Author : Dong 
# @File : mitmproxy_js.py
from mitmproxy import ctx


# 所有的请求都会经过request


def request(flow):
    info = ctx.log.info
    # info(flow.request.url)
    # info(str(flow.request.headers))
    # info(str(flow.request.cookies))
    # info(flow.request.host)
    # info(flow.request.method)
    # info(str(flow.request.port))
    # info(flow.request.scheme)
    # print('=' * 30)
    # print(flow.request.method, ":", flow.request.url)
    # print('=' * 30)


def response(flow):
    info = ctx.log.info
    if 'um.js' in flow.request.url or '118.js' in flow.request.url:
        # 屏蔽selenium检测
        flow.response.text = flow.response.text + \
                             'Object.defineProperties(navigator,{webdriver:{get:() => false}}); '
